//
//  WJUIBarButtonItem.swift
//  WJWeiBo
//
//  Created by wangjun on 16/7/20.
//  Copyright © 2016年 wangjun. All rights reserved.
//

import UIKit

class WJUIBarButtonItem: UIBarButtonItem {
    
 init(title: String? = nil,imgName: String? = nil,target: AnyObject?, action: Selector) {
        super.init()
        
        let button = UIButton()
        if let tit = title {
            
            button.setTitle(tit, forState: UIControlState.Normal)
            button.titleLabel?.font = UIFont.systemFontOfSize(20)
            button.setTitleColor(UIColor.orangeColor(), forState: UIControlState.Normal)
            
        }
        
        if let img = imgName {
            
            button.setImage(UIImage(named: img), forState: UIControlState.Normal)
            
        }
     button.addTarget(target, action: action, forControlEvents: UIControlEvents.TouchUpInside)
    
        button.sizeToFit()
        self.customView = button
        
    }

 required init?(coder aDecoder: NSCoder) {
     fatalError("init(coder:) has not been implemented")
 }

    
}
